import requests

def get_local_service(endpoint, params=None):
    """
    包装的 requests.get 函数，用于调用本地 8081 端口的服务。
    
    :param endpoint: 服务的端点路径，例如 "/api/data"
    :param params: 可选的查询参数字典
    :return: 服务的响应内容
    """
    base_url = "http://localhost:8081"
    url = f"{base_url}{endpoint}"
    
    try:
        response = requests.get(url, params=params)
        response.raise_for_status()  # 检查请求是否成功
        return response.text
    except requests.RequestException as e:
        print(f"请求失败: {e}")
        return None

# 示例用法
if __name__ == "__main__":
    # 调用本地服务的示例
    result = get_local_service("/api/data", {"param1": "value1", "param2": "value2"})
    if result:
        print("服务响应:", result)